package com.monday.graphql.provider;

import com.monday.graphql.resolver.BookResolver;
import com.monday.graphql.resolver.Query;
import graphql.GraphQL;
import graphql.kickstart.tools.SchemaParser;
import graphql.schema.GraphQLSchema;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

@Component
public class GraphQLProvider {

    @Bean
    public GraphQL createGraphQL(){
        GraphQLSchema schema = SchemaParser.newParser()
                .file("schema.graphqls")
                .resolvers(new Query(), new BookResolver())
                .build()
                .makeExecutableSchema();

        return GraphQL.newGraphQL(schema).build();
    }


}
